<template>
	<view>
		<view class="cash_out__item" v-for="item in list" :key="item.id">
			<view class="cash_out__head">
				<text>￥{{ item.amount }}</text>
				<text>{{ statusArr[item.status] }}</text>
			</view>
			<view class="text_right text_grey">{{ item.created_at }}</view>
		</view>
		<view style="height: 40rpx;"></view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	import {withdrawLog} from '@/common/api.js'
	
	export default {
		data() {
			return {
				list: [],
				page: 1,
				status: 'loadmore',
				statusArr: ['审核中', '审核通过', '已拒绝']
			};
		},
		onShow() {
			this._withdrawLog()
		},
		methods: {
			_withdrawLog() {
				this.status = 'loading';
				withdrawLog({page: this.page}).then(({data}) => {
					this.list = this.list.concat(data.list)
					if(data.current_page >= data.total_page) this.status = 'nomore';
									else this.status = 'loading';
				})
			}
		},
		onReachBottom() {
			if (this.status == 'nomore') return;
			this.page++;
			this._withdrawLog();
		}
	}
</script>

<style lang="scss" scoped>
	.text_grey {
		color: #999;
	}
	.cash_out__item {
		border-radius: 8px;
		background: #ffffff;
		box-shadow:  20rpx 20rpx 40rpx #d9d9d9,
		             -20rpx -20rpx 40rpx #ffffff;
		margin: 10px 10px 0;
		padding: 20rpx;
	}
	.cash_out__head {
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
		> text {
			&:first-child {
				font-size: 16px;
			}
			&:last-child {
				color: #999;
				font-size: 24rpx;
			}
		}
	}
	.text_right {
		text-align: right;
	}
</style>
